home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 34.zip / BS1 part 34 / Music Util v1.5 TPL.adf / ST2.4.Replay.s < prev    next >
Text File  |  1978-01-31  |  7KB  |  422 lines

  1. ; -----------------------------------------------
  2. ; ------- Soundtracker V2.4 - playroutine -------
  3. ; -----------------------------------------------
  4.  
  5. ; call 'mt_init' to initialize the playroutine
  6.  
  7. mt_init:lea    mt_data,a0
  8.     add.l    #$03b8,a0
  9.     moveq    #$7f,d0
  10.     moveq    #0,d1
  11. mt_init1:
  12.     move.l    d1,d2
  13.     subq.w    #1,d0
  14. mt_init2:
  15.     move.b    (a0)+,d1
  16.     cmp.b    d2,d1
  17.     bgt.s    mt_init1
  18.     dbf    d0,mt_init2
  19.     addq.b    #1,d2
  20.  
  21. mt_init3:
  22.     lea    mt_data,a0
  23.     lea    mt_sample1(pc),a1
  24.     asl.l    #8,d2
  25.     asl.l    #2,d2
  26.     add.l    #$438,d2
  27.     add.l    a0,d2
  28.     moveq    #$1e,d0
  29. mt_init4:
  30.     move.l    d2,(a1)+
  31.     moveq    #0,d1
  32.     move.w    42(a0),d1
  33.     asl.l    #1,d1
  34.     add.l    d1,d2
  35.     add.l    #$1e,a0
  36.     dbf    d0,mt_init4
  37.  
  38.     lea    mt_sample1(PC),a0
  39.     moveq    #0,d0
  40. mt_clear:
  41.     move.l    (a0,d0.w),a1
  42.     clr.l    (a1)
  43.     addq.w    #4,d0
  44.     cmp.w    #$7c,d0
  45.     bne.s    mt_clear
  46.  
  47.     clr.w    $dff0a8
  48.     clr.w    $dff0b8
  49.     clr.w    $dff0c8
  50.     clr.w    $dff0d8
  51.     clr.l    mt_partnrplay
  52.     clr.l    mt_partnote
  53.     clr.l    mt_partpoint
  54.  
  55.     move.b    mt_data+$3b6,mt_maxpart+1
  56.     rts
  57.  
  58. ; call 'mt_end' to switch the sound off
  59.  
  60. mt_end:    clr.w    $dff0a8
  61.     clr.w    $dff0b8
  62.     clr.w    $dff0c8
  63.     clr.w    $dff0d8
  64.     move.w    #$f,$dff096
  65.     rts
  66.  
  67. ; the playroutine - call this every frame
  68.  
  69. mt_music:
  70.     addq.w    #1,mt_counter
  71. mt_cool:cmp.w    #6,mt_counter
  72.     bne.s    mt_notsix
  73.     clr.w    mt_counter
  74.     bra    mt_rout2
  75.  
  76. mt_notsix:
  77.     lea    mt_aud1temp(PC),a6
  78.     tst.b    3(a6)
  79.     beq.s    mt_arp1
  80.     lea    $dff0a0,a5        
  81.     bsr.s    mt_arprout
  82. mt_arp1:lea    mt_aud2temp(PC),a6
  83.     tst.b    3(a6)
  84.     beq.s    mt_arp2
  85.     lea    $dff0b0,a5
  86.     bsr.s    mt_arprout
  87. mt_arp2:lea    mt_aud3temp(PC),a6
  88.     tst.b    3(a6)
  89.     beq.s    mt_arp3
  90.     lea    $dff0c0,a5
  91.     bsr.s    mt_arprout
  92. mt_arp3:lea    mt_aud4temp(PC),a6
  93.     tst.b    3(a6)
  94.     beq.s    mt_arp4
  95.     lea    $dff0d0,a5
  96.     bra.s    mt_arprout
  97. mt_arp4:rts
  98.  
  99. mt_arprout:
  100.     move.b    2(a6),d0
  101.     and.b    #$0f,d0
  102.     tst.b    d0
  103.     beq    mt_arpegrt
  104.     cmp.b    #$01,d0
  105.     beq.s    mt_portup
  106.     cmp.b    #$02,d0
  107.     beq.s    mt_portdwn
  108.     cmp.b    #$0a,d0
  109.     beq.s    mt_volslide
  110.     rts
  111.  
  112. mt_portup:
  113.     moveq    #0,d0
  114.     move.b    3(a6),d0
  115.     sub.w    d0,22(a6)
  116.     cmp.w    #$71,22(a6)
  117.     bpl.s    mt_ok1
  118.     move.w    #$71,22(a6)
  119. mt_ok1:    move.w    22(a6),6(a5)
  120.     rts
  121.  
  122. mt_portdwn:
  123.     moveq    #0,d0
  124.     move.b    3(a6),d0
  125.     add.w    d0,22(a6)
  126.     cmp.w    #$538,22(a6)
  127.     bmi.s    mt_ok2
  128.     move.w    #$538,22(a6)
  129. mt_ok2:    move.w    22(a6),6(a5)
  130.     rts
  131.  
  132. mt_volslide:
  133.     moveq    #0,d0
  134.     move.b    3(a6),d0
  135.     lsr.b    #4,d0
  136.     tst.b    d0
  137.     beq.s    mt_voldwn
  138.     add.w    d0,18(a6)
  139.     cmp.w    #64,18(a6)
  140.     bmi.s    mt_ok3
  141.     move.w    #64,18(a6)
  142. mt_ok3:    move.w    18(a6),8(a5)
  143.     rts
  144. mt_voldwn:
  145.     moveq    #0,d0
  146.     move.b    3(a6),d0
  147.     and.b    #$0f,d0
  148.     sub.w    d0,18(a6)
  149.     bpl.s    mt_ok4
  150.     clr.w    18(a6)
  151. mt_ok4:    move.w    18(a6),8(a5)
  152.     rts
  153.  
  154. mt_arpegrt:
  155.     move.w    mt_counter(PC),d0
  156.     cmp.w    #1,d0
  157.     beq.s    mt_loop2
  158.     cmp.w    #2,d0
  159.     beq.s    mt_loop3
  160.     cmp.w    #3,d0
  161.     beq.s    mt_loop4
  162.     cmp.w    #4,d0
  163.     beq.s    mt_loop2
  164.     cmp.w    #5,d0
  165.     beq.s    mt_loop3
  166.     rts
  167.  
  168. mt_loop2:
  169.     moveq    #0,d0
  170.     move.b    3(a6),d0
  171.     lsr.b    #4,d0
  172.     bra.s    mt_cont
  173. mt_loop3:
  174.     moveq    #$00,d0
  175.     move.b    3(a6),d0
  176.     and.b    #$0f,d0
  177.     bra.s    mt_cont
  178. mt_loop4:
  179.     move.w    16(a6),d2
  180.     bra.s    mt_endpart
  181. mt_cont:
  182.     add.w    d0,d0
  183.     moveq    #0,d1
  184.     move.w    16(a6),d1
  185.     and.w    #$fff,d1
  186.     lea    mt_arpeggio(PC),a0
  187. mt_loop5:
  188.     move.w    (a0,d0),d2
  189.     cmp.w    (a0),d1
  190.     beq.s    mt_endpart
  191.     addq.l    #2,a0
  192.     bra.s    mt_loop5
  193. mt_endpart:
  194.     move.w    d2,6(a5)
  195.     rts
  196.  
  197. mt_rout2:
  198.     lea    mt_data,a0
  199.     move.l    a0,a3
  200.     add.l    #$0c,a3
  201.     move.l    a0,a2
  202.     add.l    #$3b8,a2
  203.     add.l    #$43c,a0
  204.     move.l    mt_partnrplay(PC),d0
  205.     moveq    #0,d1
  206.     move.b    (a2,d0),d1
  207.     asl.l    #8,d1
  208.     asl.l    #2,d1
  209.     add.l    mt_partnote(PC),d1
  210.     move.l    d1,mt_partpoint
  211.     clr.w    mt_dmacon
  212.  
  213.     lea    $dff0a0,a5
  214.     lea    mt_aud1temp(PC),a6
  215.     bsr    mt_playit
  216.     lea    $dff0b0,a5
  217.     lea    mt_aud2temp(PC),a6
  218.     bsr    mt_playit
  219.     lea    $dff0c0,a5
  220.     lea    mt_aud3temp(PC),a6
  221.     bsr    mt_playit
  222.     lea    $dff0d0,a5
  223.     lea    mt_aud4temp(PC),a6
  224.     bsr    mt_playit
  225.     move.w    #$01f4,d0
  226. mt_rls:    dbf    d0,mt_rls
  227.  
  228.     move.w    #$8000,d0
  229.     or.w    mt_dmacon,d0
  230.     move.w    d0,$dff096
  231.  
  232.     lea    mt_aud4temp(PC),a6
  233.     cmp.w    #1,14(a6)
  234.     bne.s    mt_voice3
  235.     move.l    10(a6),$dff0d0
  236.     move.w    #1,$dff0d4
  237. mt_voice3:
  238.     lea    mt_aud3temp(PC),a6
  239.     cmp.w    #1,14(a6)
  240.     bne.s    mt_voice2
  241.     move.l    10(a6),$dff0c0
  242.     move.w    #1,$dff0c4
  243. mt_voice2:
  244.     lea    mt_aud2temp(PC),a6
  245.     cmp.w    #1,14(a6)
  246.     bne.s    mt_voice1
  247.     move.l    10(a6),$dff0b0
  248.     move.w    #1,$dff0b4
  249. mt_voice1:
  250.     lea    mt_aud1temp(PC),a6
  251.     cmp.w    #1,14(a6)
  252.     bne.s    mt_voice0
  253.     move.l    10(a6),$dff0a0
  254.     move.w    #1,$dff0a4
  255. mt_voice0:
  256.     move.l    mt_partnote(PC),d0
  257.     add.l    #$10,d0
  258.     move.l    d0,mt_partnote
  259.     cmp.l    #$400,d0
  260.     bne.s    mt_stop
  261. mt_higher:
  262.     clr.l    mt_partnote
  263.     addq.l    #1,mt_partnrplay
  264.     moveq    #0,d0
  265.     move.w    mt_maxpart(PC),d0
  266.     move.l    mt_partnrplay(PC),d1
  267.     cmp.l    d0,d1
  268.     bne.s    mt_stop
  269.     clr.l    mt_partnrplay
  270.     st    Pflag
  271. mt_stop:tst.w    mt_status
  272.     beq.s    mt_stop2
  273.     clr.w    mt_status
  274.     bra.s    mt_higher
  275. mt_stop2:
  276.     rts
  277.  
  278. mt_playit:
  279.     move.l    (a0,d1.l),(a6)
  280.     addq.l    #4,d1
  281.     moveq    #0,d2
  282.     move.b    2(a6),d2
  283.     and.b    #$f0,d2
  284.     lsr.b    #4,d2
  285.  
  286.     move.b    (a6),d0
  287.     and.b    #$f0,d0
  288.     or.b    d0,d2
  289.     tst.b    d2
  290.     beq.s    mt_nosamplechange
  291.  
  292.     moveq    #0,d3
  293.     lea    mt_samples(PC),a1
  294.     move.l    d2,d4
  295.     asl.l    #2,d2
  296.     mulu    #$1e,d4
  297.     move.l    (a1,d2),4(a6)
  298.     move.w    (a3,d4.l),8(a6)
  299.     move.w    2(a3,d4.l),18(a6)
  300.     move.w    4(a3,d4.l),d3
  301.     tst.w    d3
  302.     beq.s    mt_displace
  303.     move.l    4(a6),d2
  304.     add.l    d3,d2
  305.     move.l    d2,4(a6)
  306.     move.l    d2,10(a6)
  307.     move.w    6(a3,d4.l),8(a6)
  308.     move.w    6(a3,d4.l),14(a6)
  309.     move.w    18(a6),8(a5)
  310.     bra.s    mt_nosamplechange
  311.  
  312. mt_displace:
  313.     move.l    4(a6),d2
  314.     add.l    d3,d2
  315.     move.l    d2,10(a6)
  316.     move.w    6(a3,d4.l),14(a6)
  317.     move.w    18(a6),8(a5)
  318. mt_nosamplechange:
  319.     move.w    (a6),d0
  320.     and.w    #$fff,d0
  321.     tst.w    d0
  322.     beq.s    mt_retrout
  323.     move.w    (a6),16(a6)
  324.     move.w    20(a6),$dff096
  325.     move.l    4(a6),(a5)
  326.     move.w    8(a6),4(a5)
  327.     move.w    (a6),d0
  328.     and.w    #$fff,d0
  329.     move.w    d0,6(a5)
  330.     move.w    20(a6),d0
  331.     or.w    d0,mt_dmacon
  332.  
  333. mt_retrout:
  334.     tst.w    (a6)
  335.     beq.s    mt_nonewper
  336.     move.w    (a6),22(a6)
  337.  
  338. mt_nonewper:
  339.     move.b    2(a6),d0
  340.     and.b    #$0f,d0
  341.     cmp.b    #$0b,d0
  342.     beq.s    mt_posjmp
  343.     cmp.b    #$0c,d0
  344.     beq.s    mt_setvol
  345.     cmp.b    #$0d,d0
  346.     beq.s    mt_break
  347.     cmp.b    #$0e,d0
  348.     beq.s    mt_setfil
  349.     cmp.b    #$0f,d0
  350.     beq.s    mt_setspeed
  351.     rts
  352.  
  353. mt_posjmp:
  354.     not.w    mt_status
  355.     moveq    #0,d0
  356.     move.b    3(a6),d0
  357.     subq.b    #1,d0
  358.     move.l    d0,mt_partnrplay
  359.     rts
  360.  
  361. mt_setvol:
  362.     move.b    3(a6),8(a5)
  363.     rts
  364.  
  365. mt_break:
  366.     not.w    mt_status
  367.     rts
  368.  
  369. mt_setfil:
  370.     moveq    #0,d0
  371.     move.b    3(a6),d0
  372.     and.b    #1,d0
  373.     rol.b    #1,d0
  374.     and.b    #$fd,$bfe001
  375.     or.b    d0,$bfe001
  376.     rts
  377.  
  378. mt_setspeed:
  379.     move.b    3(a6),d0
  380.     and.b    #$0f,d0
  381.     beq.s    mt_back
  382.     clr.w    mt_counter
  383.     move.b    d0,mt_cool+3
  384. mt_back:rts
  385.  
  386. mt_aud1temp:
  387.     blk.w    10,0
  388.     dc.w    1
  389.     blk.w    2,0
  390. mt_aud2temp:
  391.     blk.w    10,0
  392.     dc.w    2
  393.     blk.w    2,0
  394. mt_aud3temp:
  395.     blk.w    10,0
  396.     dc.w    4
  397.     blk.w    2,0
  398. mt_aud4temp:
  399.     blk.w    10,0
  400.     dc.w    8
  401.     blk.w    2,0
  402.  
  403. mt_partnote:    dc.l    0
  404. mt_partnrplay:    dc.l    0
  405. mt_counter:    dc.w    0
  406. mt_partpoint:    dc.l    0
  407. mt_samples:    dc.l    0
  408. mt_sample1:    blk.l    31,0
  409. mt_maxpart:    dc.w    0
  410. mt_dmacon:    dc.w    0
  411. mt_status:    dc.w    0
  412.  
  413. mt_arpeggio:
  414.     dc.w $0358,$0328,$02fa,$02d0,$02a6,$0280,$025c
  415.     dc.w $023a,$021a,$01fc,$01e0,$01c5,$01ac,$0194,$017d
  416.     dc.w $0168,$0153,$0140,$012e,$011d,$010d,$00fe,$00f0
  417.     dc.w $00e2,$00d6,$00ca,$00be,$00b4,$00aa,$00a0,$0097
  418.     dc.w $008f,$0087,$007f,$0078,$0071,$0000,$0000,$0000
  419.  
  420. mt_data:    blk.b    0,0    ;the first value represents the length
  421.                 ;of the module
  422.